package com.magic.consumer.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class DelayExchangeConfig {

    //@Bean
    public DirectExchange delayExchange() {
        return ExchangeBuilder
                .directExchange("delay.direct") //指定交换机类型和名称
                .delayed() //设置delay的属性为true
                .durable(true) //持久化
                .build();
    }

    //@Bean
    public Queue delayedQueue() {
        return new Queue("delay.queue");
    }

    //@Bean
    public Binding delayQueueBinding() {
        return BindingBuilder.bind(delayedQueue()).to(delayExchange()).with("delay");
    }
}